package model

import (
	"database/sql"
	"time"
)

type HrDepartment struct {
	ResCommon
	Name                    string        `json:"name"`
	CompleteName            string        `json:"complete_name"`
	ParentId                sql.NullInt64 `json:"parent_id"`
	ParentPath              string        `json:"parent_path"`
	MessageMainAttachmentId sql.NullInt64
	Active                  bool
	CompanyId               int64
	ManagerId               int64
	Note                    string
	Color                   int
	AdminId                 int64
}

type HrEmployee struct {
	ResCommon
	EmployeeType                string        `json:"employee_type"`
	UserId                      sql.NullInt64 `json:"user_id"`
	User                        ResUsers
	DepartmentId                sql.NullInt64 `json:"department_id"`
	Department                  HrDepartment
	ResourceId                  int64
	CompanyId                   int64
	Company                     ResCompany
	ResourceCalendarId          int
	MessageMainAttachmentId     sql.NullInt64
	Name                        string
	Active                      bool
	Color                       int
	JobId                       sql.NullInt64
	Job                         HrJob
	JobTitle                    string
	AddressId                   int
	WorkPhone                   string
	MobilePhone                 string
	WorkEmail                   string
	WorkLocationId              int
	ParentId                    int
	CoachId                     int
	AddressHomeId               int64
	CountryId                   int
	Gender                      string
	Marital                     string
	SpouseCompleteName          string
	SpouseBirthdate             sql.NullTime
	Children                    int
	PlaceOfBirth                string
	CountryOfBirth              int
	Birthday                    sql.NullTime
	Ssnid                       string
	Sinid                       string
	IdentificationId            string
	PassportId                  string
	BankAccountId               sql.NullInt64
	PermitNo                    string
	VisaNo                      string
	VisaExpire                  time.Time
	WorkPermitExpirationDate    time.Time
	WorkPermitScheduledActivity bool
	AdditionalNote              string
	Certificate                 string
	StudyField                  string
	StudySchool                 string
	EmergencyContact            string
	EmergencyPhone              string
	KmHomeWork                  int
	Notes                       string
	Barcode                     string
	Pin                         string
	DepartureReasonId           int
	DepartureDescription        string
	DepartureDate               time.Time
	Vehicle                     string
	ContractId                  int
	ContractWarning             bool
	FirstContractDate           time.Time
	ExpenseManagerId            int
	LastCheckIn                 sql.NullTime
	LastCheckOut                sql.NullTime
	LastAttendanceId            sql.NullInt64
	IsAuth                      bool
	Status                      string
	WorkContactId               int64
}

type CrmTeam struct {
	ResCommon
	Name string `json:"name"`
	//AliasId   int64         `json:"alias_id"`
	//ParentId  sql.NullInt64 `json:"parent_id"`
	Active    bool          `json:"active" gorm:"default:true"`
	CompanyId sql.NullInt64 `json:"company_id"`
	UserId    sql.NullInt64
}
type ResUsersCrmTeamRel struct {
	UserId int64
	TeamId int64
}
type CrmTeamMember struct {
	ResCommon
	CrmTeamId int64
	UserId    int64
	Active    bool
}
type HrJob struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	Sequence                int
	ExpectedEmployees       int
	NoOfEmployee            int
	NoOfRecruitment         int
	NoOfHiredEmployee       int
	Description             string
	Requirements            string
	DepartmentId            int
	CompanyId               int64
	State                   string
}

type HrWorkLocation struct {
	ResCommon
	Active         bool
	Name           string
	CompanyId      int
	AddressId      int
	LocationNumber string
}

type HrEmployeeCategory struct {
	ResCommon
	Name  string
	Color int
}

type HrDepartureReason struct {
	ResCommon
	Sequence int
	Name     string
}

type HrPlanActivityType struct {
	ResCommon
	ActivityTypeId int
	Summary        string
	Responsible    string
	ResponsibleId  int
	Note           string
}

type HrPlan struct {
	ResCommon
	Name   string
	Active bool
}

type HrPlanHrPlanActivityTypeRel struct {
	HrPlanId             int
	HrPlanActivityTypeId int
}

type HrDepartmentMailChannelRel struct {
	MailChannelId  int
	HrDepartmentId int
}

type HrPlanWizard struct {
	ResCommon
	PlanId     int
	EmployeeId int
}

type HrDepartureWizard struct {
	ResCommon
	DepartureReasonId     int
	DepartureDescription  string
	DepartureDate         time.Time
	EmployeeId            int
	ArchivePrivateAddress bool
	SetDateEnd            bool
}

type HrContractType struct {
	ResCommon
	Name string
}

type HrContract struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	Active                  bool
	StructureTypeId         int
	StructureType           HrPayrollStructureType
	EmployeeId              sql.NullInt64
	Employee                HrEmployee
	DepartmentId            sql.NullInt64
	JobId                   sql.NullInt64
	Job                     HrJob
	DateStart               time.Time
	DateEnd                 sql.NullTime
	DateGeneratedFrom       time.Time
	DateGeneratedTo         time.Time
	TrialDateEnd            time.Time
	ResourceCalendarId      sql.NullInt64
	Wage                    float64
	WageOnSignature         float64
	HourlyWage              float64
	Notes                   sql.NullString
	State                   string
	CompanyId               int64
	ContractTypeId          sql.NullInt64
	KanbanState             string
	HrResponsibleId         int
	ResourceCalendar        ResourceCalendar
	WorkEntrySource         string
}

type HrPayrollStructureType struct {
	ResCommon
	Name                      string
	DefaultResourceCalendarId int
	CountryId                 int64
	WageType                  string
}

type HrExpenseSheet struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	State                   string
	PaymentState            string
	EmployeeId              int
	AddressId               int
	UserId                  int
	TotalAmount             string
	AmountResidual          string
	CompanyId               int
	CurrencyId              int
	JournalId               int
	BankJournalId           int
	AccountingDate          time.Time
	AccountMoveId           int
	DepartmentId            int
	ApprovalDate            time.Time
}

type HrExpenseRefuseWizard struct {
	ResCommon
	Reason           string
	HrExpenseSheetId int
}

type HrExpenseHrExpenseRefuseWizardRel struct {
	HrExpenseRefuseWizardId int
	HrExpenseId             int
}

type HrExpenseApproveDuplicate struct {
	ResCommon
}

type HrExpenseApproveDuplicateHrExpenseSheetRel struct {
	HrExpenseApproveDuplicateId int64
	HrExpenseSheetId            int64
}

type HrExpenseHrExpenseApproveDuplicateRel struct {
	HrExpenseApproveDuplicateId int64
	HrExpenseId                 int64
}

type HrExpenseExtractWords struct {
	ResCommon
	ExpenseId int
	WordText  string
	WordPage  int
}

type HrExpense struct {
	ResCommon
	MessageMainAttachmentId sql.NullInt64
	Name                    string
	Date                    time.Time
	AccountingDate          time.Time
	EmployeeId              int64
	ProductId               int64
	ProductUomId            int64
	UnitAmount              string
	Quantity                string
	UntaxedAmount           string
	TotalAmount             string
	TotalAmountCompany      string
	CompanyId               int64
	CurrencyId              int
	AnalyticAccountId       int
	AccountId               int
	Description             string
	PaymentMode             string
	State                   string
	SheetId                 int
	Reference               string
	IsRefused               bool
	Sample                  bool
	PredictedCategory       string
	TopTime                 time.Time
	ExtractState            string
	ExtractStatusCode       int
	ExtractRemoteId         int
	SaleOrderId             int
}

// HrAttendance 出勤
type HrAttendance struct {
	ResCommon
	EmployeeId  int64
	CheckIn     time.Time
	CheckOut    sql.NullTime
	WorkedHours float64
	//Location    sql.NullString
	//Address     sql.NullString
}

type ResourceResource struct {
	ResCommon
	CompanyId      int64
	UserId         sql.NullInt64
	CalendarId     int64
	Name           string
	ResourceType   string
	Tz             string
	Active         bool
	TimeEfficiency float64
	Color          int
	FlexibleHours  bool
}
